import { QuestDefaultApi } from '@/library/util/api';
import { defaultErrorHandler } from '@/library/util/error-handler';
import { User } from '@/services/quest';
import { message } from 'ant-design-vue';
import { defineStore } from 'pinia';
interface EditUserState {
  isloading: boolean;
}
export const useEditUserStore = defineStore({
  id: 'EditUserStore',
  state: (): EditUserState => ({
    isloading: false,
  }),
  actions: {
    /**
     * 编辑用户信息
     * @param params
     */
    async editInfor(params: User) {
      try {
        this.isloading = true;
        await QuestDefaultApi.userConfigPost(params);

        message.success('编辑成功');
      } catch (error) {
        defaultErrorHandler(error);
      } finally {
        this.isloading = false;
      }
    },
  },
});
